<template>
  <div class="ikun-header-container">
    <!-- 菜单隐藏按钮 -->
    <div class="ikun-header-change" @click="changeAside">
      <i class="el-icon-s-fold"></i>
    </div>
    <el-switch v-model="value" active-color="#666" inactive-color="#f1f1f1" active-icon-class="el-icon-moon"
      inactive-icon-class="el-icon-sunny" @change="change">
    </el-switch>
    <!-- 头像下拉-->
    <div class="ikun-headsculpture">
      <el-dropdown class="ikun-dropdown" trigger="click">
        <span class="el-dropdown-link">
          <el-avatar :size="'small'" :src="hearUrl" style="vertical-align: middle;"></el-avatar>
          <i class="el-icon-arrow-down el-icon--right"></i>
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>
            <el-button type="text" @click="showUserInfo">我的信息</el-button>
          </el-dropdown-item>
          <el-dropdown-item >
            <el-button type="text" @click="updatePwd">修改密码</el-button>
          </el-dropdown-item>
          <el-dropdown-item >
            <el-button type="text" @click="logout">退出登录</el-button>
          </el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </div>
</template>

<script lang="ts">
import { Component, Vue, Emit } from "vue-property-decorator";
@Component({
  components: {},
})
export default class Header extends Vue {
  // 头像地址
  hearUrl: string = "/static/images/avatar.gif";
  value: boolean = true;
  htmlTag: any = document.documentElement;
  // 切换背景色
  change(val: boolean) {
    if (val) {
      this.htmlTag.classList.add("dark");
      this.htmlTag.classList.remove("light");
    } else {
      this.htmlTag.classList.add("light");
      this.htmlTag.classList.remove("dark");
    }
  }
  @Emit()
  changeAside() { }
  logout() {
    this.$message.success("摸鱼还想退出？")
  }
  showUserInfo() {
    this.$message.success("还没写")
  }
  updatePwd() {
    this.$message.error("QQ群754126966问群友");
  }
}
</script>
<style lang="stylus">
@import "./style.styl"
</style>
